package org.example.l2;

import java.util.Deque;
import java.util.LinkedList;

public class MinStack {

    Deque<Integer> min;
    Deque<Integer> normal;

    public MinStack() {
        min = new LinkedList<>();
        min.offer(Integer.MAX_VALUE);
        normal = new LinkedList<>();
    }

    public void push(int val) {
        normal.push(val);
        Integer peek = min.peek();
        min.push(Math.min(val, peek));
    }

    public void pop() {
        normal.pop();
        min.pop();
    }

    public int top() {
        return normal.peek();
    }

    public int getMin() {
        return min.peek();
    }
}
